<template>
  <el-container class="muzi">
    <el-header>
      <div class="left-panel">
        <el-button type="primary" @click="onCreate" plain>添加</el-button>
      </div>
      <div class="right-panel">
      </div>
    </el-header>
    <el-main>
      <el-table :data="dataList" border>
        <el-table-column type="selection" width="45"/>
        <el-table-column prop="name" label="名称" align="center"/>
        <el-table-column fixed="right" label="操作" width="175" align="center">
          <template #default="scope">
            <el-button type="danger" icon="el-icon-delete" circle size="small" @click="onRemove(scope.row)"/>
          </template>
        </el-table-column>
      </el-table>
    </el-main>
  </el-container>
  <TeamForm v-if="show.form" ref="FormHandle" @success="onSearch" @closed="show.form=false"/>
</template>

<script>
import TeamForm from "@/views/project/team-form";

/**
 * 页面施工中
 * @author Yufe
 * @version 1.0
 */
export default {
  name: '项目资料',
  components: {TeamForm},
  data() {
    return {
      show: {
        form: false
      },
      dataList: [],
      project: {id: null}
    }
  },
  mounted() {
    this.project.id = this.$route.params.id;
    this.onSearch();
  },
  computed: {},
  methods: {
    onSearch() {
      this.$API.project.team.list.get(this.project.id).then(res => {
        if (res.success) {
          this.dataList = res.data;
        }
      })
    },
    onCreate() {
      this.show.form = true
      this.$nextTick(() => {
        this.$refs.FormHandle.open().data(this.project)
      })
    },
    onRemove(row) {
      this.$API.project.team.detail.delete(this.project.id, row.id).then(res => {
        if (res.success) {
          this.onSearch();
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
</style>
